package org.ejc.struts.preregistration;

import java.io.File;
import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Category;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;


/**
 * @struts.action path="/struts/preregistration/preRegistrationAction" scope="request"
 *                parameter="methodToCall" name="preRegistrationForm"
 *                validate="false"
 *                input="/struts/login/home.jsp"
 * 
 * @struts.action-forward name="createSuccess" path="/struts/login/home.jsp"
 * 
 * 
 * @author zac, Brian Boyle
 *
 */
public class PreRegistrationAction extends DispatchAction {

	Category log = Category.getInstance(PreRegistrationAction.class);
	/* (non-Javadoc)
	 * @see org.apache.struts.actions.DispatchAction#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		PreRegistrationForm preRegForm = (PreRegistrationForm) form;
		//Process the FormFile
        File myFile = preRegForm.getPreRegFile();
    
		/*//CSVReader reader = new CSVReader(new FileReader(myFile));
		reader.readAll();
		String [] nextLine;
		while ((nextLine = reader.readNext()) != null) {
			log.debug("CountryCode: [" + nextLine[0] + "]\nPreRegCode: [" + nextLine[1] + "]\nAmount: [" + nextLine[2] + "]" +
					"\nCurrency: [" + nextLine[3] + "]\nFirstName: [" + nextLine[4] + "]\nLast Name: [" + nextLine[5] + "]" +
					"\nAddress1: [" + nextLine[6] + "]");*/
		
		return null;
	}

	

}
